package com.wyd.qxglht.dao;

import java.util.List;

import javax.transaction.Transactional;

import com.wyd.qxglht.model.Users;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface IUsersDao extends JpaRepository<Users, String>, JpaSpecificationExecutor<Users> {


    //重置密码
    @Transactional
    @Modifying
    @Query("update Users u set u.password='ysd123' where u.id=:id")
    int pwdReset(String id);
    //锁定
    @Transactional
    @Modifying
    @Query("update Users u set u.isLockout='是' where u.id=:id")
    int lockoutUser(String id);
    //解锁
    @Transactional
    @Modifying
    @Query("update Users u set u.isLockout='否' where u.id=:id")
    int notLockoutUser(String id);

     //修改用户
     @Transactional
     @Modifying
     @Query("update Users u set u.loginName=:loginName,u.protectEMail=:protectEMail,u.protectMTel=:protectMTel where u.id=:id")
     int editUser(String id,String loginName,String protectEMail,String protectMTel);

 //删除用户
 @Transactional
 @Modifying
 @Query("delete Users u  where u.id=:id")
 int delUser(String id);



     //登录
    
    @Query("select u from Users u where u.loginName = :loginName and u.password=:password")
    List<Users> login(String loginName,String password);


    //根据id查询用户

    @Query("select u from Users u where u.id=:id")
        Users findOne(String id);



        




}